﻿namespace SampleApplication.Library
{
    using System;
    using Codeplex.Unity.AutoRegister;
    using Microsoft.Practices.Unity;

    // annotation base regist
    [UnityExport]
    public class GreeterClient
    {
        [Dependency]
        public IGreeter Greeter { get; set; }

        public void Execute()
        {
            Console.WriteLine(this.Greeter.Greet());
        }
    }

    public interface IGreeter
    {
        string Greet();
    }

    // multi regist
    [UnityExport(FromType = typeof(IGreeter))]
    // set LifetimeManager
    [UnityExport(Name = "Singleton", 
        FromType = typeof(IGreeter), 
        LifetimeManager = typeof(ContainerControlledLifetimeManager))]
    public class Greeter : IGreeter
    {
        public string Greet()
        {
            return "Hello world";
        }
    }
}
